package org.example.completed.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;

//User类主要用于Java数据和数据库表的映射
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    private String id;  // id
    private String userAcoount; // 用户名
    private String username;    // 账户
    private String password;    // 密码
    private String img;     // 头像
    private BigDecimal money;
    private String Sex;     // 性别
    private String age;     // 年龄
    private Integer isDelete;
    private String rights;        // 权益类型 (vip 或 普通用户)

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    public void setMoney(BigDecimal money) {
        if (money.compareTo(BigDecimal.ZERO) < 0) {
            throw new IllegalArgumentException("余额不能为负数");
        }
        this.money = money;
    }
}